package com.bsj.power.pls.config.net.netty.gpgga;

import com.bsj.power.common.constant.NumericalConstants;
import com.bsj.power.pls.config.net.netty.common.client.RTKTcpClientConstant;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author LiJiaXin
 * @version 1.0.0
 * @description GpggaTcpClientConstant
 * @time 2024/11/28 14:02
 */
@Component
public class GpggaTcpClientConstant {

    public static String unitOneIp;
    public static String unitTwoIp;
    public static Integer unitOnePort;
    public static Integer unitTwoPort;

    @Value("${gpgga.unitOne.ip}")
    public void setUnitOneIp(String ip) {
        this.unitOneIp = ip;
    }

    @Value("${gpgga.unitTwo.ip}")
    public void setUnitTwoIp(String ip) {
        this.unitTwoIp = ip;
    }


    @Value("${gpgga.unitOne.port}")
    public void setUnitOnePort(Integer port) {
        this.unitOnePort = port;
    }


    @Value("${gpgga.unitTwo.port}")
    public void setUnitTwoPort(Integer port) {
        this.unitTwoPort = port;
    }

    public static String getIp(int unitNo) {
        String ip = null;
        if (unitNo == NumericalConstants.ONE) {
            ip = unitOneIp;
        } else if (unitNo == NumericalConstants.TWO) {
            ip = unitTwoIp;
        }
        return ip;
    }

    public static Integer getPort(int unitNo) {
        Integer port = null;
        if (unitNo == NumericalConstants.ONE) {
            port = unitOnePort;
        } else if (unitNo == NumericalConstants.TWO) {
            port = unitTwoPort;
        }
        return port;
    }

}
